<?php echo $this->partial("sidebar.phtml", array('type' => 'product', 'cartdata' => $this->cartdata, 'params' => $this->params)); ?>
<div class="cart-page vertical-scroller">
    <div class="pull-left">
        <p class="notes-text"><img src="<?php echo IMAGES_PATH; ?>/lock.png"> We offer a secure shopping experience</p>
        <p class="notes-text"><img src="<?php echo IMAGES_PATH; ?>/note arrow.png"> We guarantee it's on-time or the shopping is on us.</p>
    </div>
    <div class="pull-right" style="margin-bottom:10px;">
        <?php
            if (count($this->cartdata) && is_array($this->cartdata))
            {
                ?>
                <!--<button type="submit" name="submit" class="btn btn-checkout-2">PROCEED TO CHECKOUT ></button>-->
                <a href="<?php echo $this->baseUrl('cart/checkoutpaypal'); ?>" class="btn btn-checkout-2">PROCEED TO CHECKOUT</a>
                <?php
            }
        ?>
    </div>
    <div class="raeken-cart">
        <div class="cart-header">
            <div class="product-name">
                PRODUCT
            </div>
            <div class="product-feature">
                MY OPTIONS
            </div>
            <div class="product-price">
                PRICE
            </div>
            <div class="product-total">
                ITEM TOTAL
            </div>
        </div>

        <?php
            if (count($this->cartdata) && is_array($this->cartdata))
            {
                foreach ($this->cartdata as $cartKey => $cartVal)
                {
                    ?>
                    <div class="product-body">
                        <div class="product-name remove-<?php echo $cartVal['cart_id']; ?>">
                            <img class="product-img" src="<?php echo PRODUCTS_PATH; ?>/<?php echo $cartVal['images']; ?>">
                            <p class="product-desc"><strong><?php echo $cartVal['brand_name'] ?><br>
                                    <?php
                                    echo $cartVal['prod_name'];
                                    ?></strong><br>
                                Sku # <?php echo $cartVal['prod_code']; ?>
                            </p>
                        </div>
                        <div class="product-feature remove-<?php echo $cartVal['cart_id']; ?>">
                            <p><?php echo $cartVal['product_color']; ?> Color<br>
                                <?php
                                echo $cartVal['product_size'];
                                ?> SIZE<br>
                                Quantity: <?php echo $cartVal['product_quantity']; ?><br><br>
                                <!--<button class="btn btn-default" style="border-radius: 0;">Edit</button>-->
                                <a href="#" id="<?php echo $cartVal['cart_id']; ?>" class="remove-product">Remove</a>
                            </p>
                        </div>
                        <div class="product-price remove-<?php echo $cartVal['cart_id']; ?>">
                            <p>$<?php echo $cartVal['price']; ?></p>
                        </div>
                        <div class="product-total remove-<?php echo $cartVal['cart_id']; ?>">
                            <p>$<?php echo $cartVal['product_quantity'] * $cartVal['price']; ?></p>
                        </div>
                    </div>
                    <?php
                }
            }
            else
            {
                ?>
                <div class="product-body">
                    <div style="display:table-row;width:100%;color:#000;height:100px;">
                        <p style="display:table-cell;color:#000;text-align: center;">No product found in cart</p>
                    </div>
                </div>
                <?php
            }
        ?>

    </div>
    <br>
    <div class="shipping-area">
        <div class="left-area">
          Shipping Address<br>
          From User Register
          Info
        </div>
        <div class="right-area">
            <span class="pull-left color-orange">
                <?php echo $this->user['first_name']." ".$this->user["last_name"]."<br>"; 
                      echo $this->user['address']."<br>";
                      echo $this->user['zip_code']."<br>";
                      echo $this->user['location']."<br>";
                      //echo "Phone: ".$this->user;
                ?>
            </span>
            <!--<button class="btn btn-default pull-right ship-edit" >Edit</button>-->
        </div>
    </div>
    
    <div class="suggested-products" style="border-collapse:collapse;background:#e7e7e7;">
        <div class="header" style="background:#e7e7e7;border-collapse: collapse"><div style="border-collapse: collapse;">You may also like:</div></div>
        <div class="body">
            <?php
                foreach ($this->randomProducts as $randomKey => $randomValue)
                {
                    $images = $randomValue['images'];
                    $images = explode(",", $images);
                    ?>
                    <div>
                        <img class="product-img" src="<?php echo PRODUCTS_PATH ?>/<?php echo $images[0]; ?>">
                        <p>
                            <?php echo $randomValue['prod_name']; ?><br>
                            <?php echo!empty($randomValue['schild_name']) ? $randomValue['schild_name'] . "<br>" : ''; ?>
                            $<?php echo $randomValue['price']; ?>
                        </p>
                    </div>
                    <?php
                }
            ?>
        </div>
    </div>

    
    <?php
        if (count($this->cartdata) && is_array($this->cartdata))
        {
            ?>
            <div class="pricing ">
                <div class="header row">
<!--                    <p>Have a Promo Code?</p> <a href="#">details</a>
                    <div class="col-lg-6 pull-right">
                        <div class="input-group" style="height:20px;line-height:20px;">
                            <input type="text" class="form-control" style="border-radius:0;height:20px;margin:5px;">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button" style="border-radius:0;height:20px;line-height:7px;">Apply</button>
                            </span>
                        </div>
                    </div>-->
                </div>
                <div class="body">
                    <ul>
                        <li>Order Subtotal:</li>
                        <li style="text-align: right;" id="subtotal_amount">$<?php echo $this->cartdata[0]['total_price']; ?></li>
                    </ul>
                    <ul>
                        <li>Ship to Zip Code:</li>
                        <!--<li style="text-align: right;" id="shipping_amount"><button class="btn btn-default" type="button" style="border-radius:0;height:20px;line-height:7px;">Estimate</button></li>-->
                        <li style="text-align: right;" id="shipping_amount">
                            $<?php echo $this->shipping; ?>
                        </li>
                    </ul>
                    <ul>
                        <li>Sales Tax:</li>
                        <!--<li style="text-align: right;" id="tax_amount"><button class="btn btn-default" type="button" style="border-radius:0;height:20px;line-height:7px;">Estimate</button></li>-->
                        <li style="text-align: right;" id="tax_amount"><?php $registry = Zend_Registry::get('SITE_CONFIG');
    echo $registry['sales_tax']; ?>%</li>
                    </ul>
                    <ul>
                        <li style="font-weight:bold;color:#000;">Estimated Total:</li>
                        <li style="text-align: right;" id="grand_amount">$<?php echo $this->cartdata[0]['total_price'] + calculateTax($this->cartdata[0]['total_price']) + $this->shipping; ?></li>
                    </ul>
                    <ul class="qualify-text">
                        <li>YOU QUALIFY FOR FREE SHIPPING AND RETURNS</li>
                    </ul>
                    <ul>
                        <li style="width:100%;text-align: right;">
                            <!--<button type="submit" name="submit" class="btn btn-checkout-2">PROCEED TO CHECKOUT ></button>-->
                            <a href="<?php echo $this->baseUrl('cart/checkoutpaypal/shipping_code/01'); ?>" class="btn btn-checkout-2">PROCEED TO CHECKOUT</a>
                        </li>
                    </ul>
                    <ul class="checkout_group">
                        <li><button><img src="<?php echo IMAGES_PATH ?>/checkout-visa-btn.png"></button></li>
                        <li>or</li>
                        <li><button><img src="<?php echo IMAGES_PATH ?>/checkout-paypal-btn.png"></button></li>
                    </ul>
                </div>
            </div>
            <?php
        }
    ?>
</div>

<script>
    $(".remove-product").click(function(event) {
        event.preventDefault();
        var cnfrm = confirm("Sure to remove this product from cart?");
        if (cnfrm)
        {
            $(".please_wait").show();
            var cart_id = $(this).attr("id");
            //            var shipping_code = $('input[name=service_type]:checked').val();
            var shipping_code = "";
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "<?php echo $this->baseUrl("cart/remove"); ?>",
                data: {"cart_id": cart_id, "shipping_code": shipping_code},
                success: function(response) {
                    if (response.response == "1")
                    {
                        $("div.remove-" + cart_id).remove();
                        var subtotal = response.subtotal;
                        var tax = response.tax;
                        var promo = 0;
                        //                        var test_promo = $("#promo_disc_amount").html();
                        //                        var promo = test_promo.replace("$", "");
                        var shipping = response.shipping;

                        var grand_total = parseFloat(parseFloat(subtotal) + parseFloat(tax) - parseFloat(promo) + parseFloat(shipping));
                        var new_number = grand_total.toFixed(2);
                        $("#grand_amount").html("$" + new_number);
                        $("#subtotal_amount").html("$" + subtotal);
                        $("#tax_amount").html("$" + tax);
                        $("#shipping_amount").html("$" + shipping);
                        $(".please_wait").hide();

                        if (response.cartItems == "0")
                        {
                            $(".myCart").html("<center><h3>You cart is empty</h3></center>");
                        }
                    }
                }
            });
        }
    });
</script>